/**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2016-2026 hmc,Inc.All Rights Reserved.
 */
package com.sys.midware.rdb.config;

/**
 * 数据源连接池VO
 * 
 * @author mobing@b5m.com
 * @date 2015-08-11
 * @version 1.0
 */
public class RDBPoolConfig {

    /** 数据源驱动类 */
    private String driverClassName;

    /** 数据源继承的父节点配置 */
    private String url;

    /** 数据库用户名称 */
    private String username;

    /** 数据库密码 */
    private String password;

    /** 连接池初始化大小 */
    private Integer initialSize;

    /** 最大并发连接数 */
    private Integer maxActive;

    /** 连接池最小空闲 */
    private Integer minIdle;

    /** 配置获取连接等待超时的时间 */
    private Integer maxWait;

    /** 对于建立时间超过removeAbandonedTimeout的连接强制关闭 */
    private Boolean removeAbandoned;

    /** 指定连接建立多长时间就需要被强制关闭 */
    private Integer removeAbandonedTimeout;

    /** 关闭abanded连接时输出错误日志 */
    private Boolean logAbandoned;

    /** 间隔多长时间启动空闲连接回收进程，单位是毫秒 */
    private Integer timeBetweenEvictionRunsMillis;

    /** 空闲时间超过多少的连接将被回收，单位是毫秒 */
    private Integer minEvictableIdleTimeMillis;

    /** 测试有效用的SQL Query */
    private String validationQuery;

    /** 测试有效用的SQL超时时间 */
    private Integer validationQueryTimeout;

    /** 申请连接时执行validationQuery检测连接是否有效 */
    private Boolean testOnBorrow;

    /** 归还连接时执行validationQuery检测连接是否有效 */
    private Boolean testOnReturn;

    /** 连接空闲时进行连接有效检测 */
    private Boolean testWhileIdle;

    /** 是否缓存preparedStatement */
    private Boolean poolPreparedStatements;

    /** 要启用PSCache，必须配置大于0 */
    private Integer maxPoolPreparedStatementPerConnectionSize;

    /** 最大PSCache */
    private Integer maxOpenPreparedStatements;

    /** 监控统计 */
    private String filters;

    public Boolean getLogAbandoned() {
        return logAbandoned;
    }

    public void setLogAbandoned(Boolean logAbandoned) {
        this.logAbandoned = logAbandoned;
    }

    public Integer getValidationQueryTimeout() {
        return validationQueryTimeout;
    }

    public void setValidationQueryTimeout(Integer validationQueryTimeout) {
        this.validationQueryTimeout = validationQueryTimeout;
    }

    public Integer getMaxPoolPreparedStatementPerConnectionSize() {
        return maxPoolPreparedStatementPerConnectionSize;
    }

    public void setMaxPoolPreparedStatementPerConnectionSize(Integer maxPoolPreparedStatementPerConnectionSize) {
        this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
    }

    public String getDriverClassName() {
        return driverClassName;
    }

    public void setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getInitialSize() {
        return initialSize;
    }

    public void setInitialSize(Integer initialSize) {
        this.initialSize = initialSize;
    }

    public Integer getMaxActive() {
        return maxActive;
    }

    public void setMaxActive(Integer maxActive) {
        this.maxActive = maxActive;
    }

    public Integer getMinIdle() {
        return minIdle;
    }

    public void setMinIdle(Integer minIdle) {
        this.minIdle = minIdle;
    }

    public Integer getMaxWait() {
        return maxWait;
    }

    public void setMaxWait(Integer maxWait) {
        this.maxWait = maxWait;
    }

    public Integer getTimeBetweenEvictionRunsMillis() {
        return timeBetweenEvictionRunsMillis;
    }

    public void setTimeBetweenEvictionRunsMillis(Integer timeBetweenEvictionRunsMillis) {
        this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
    }

    public Integer getMinEvictableIdleTimeMillis() {
        return minEvictableIdleTimeMillis;
    }

    public void setMinEvictableIdleTimeMillis(Integer minEvictableIdleTimeMillis) {
        this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
    }

    public String getValidationQuery() {
        return validationQuery;
    }

    public void setValidationQuery(String validationQuery) {
        this.validationQuery = validationQuery;
    }

    public Boolean getTestWhileIdle() {
        return testWhileIdle;
    }

    public void setTestWhileIdle(Boolean testWhileIdle) {
        this.testWhileIdle = testWhileIdle;
    }

    public Boolean getTestOnBorrow() {
        return testOnBorrow;
    }

    public void setTestOnBorrow(Boolean testOnBorrow) {
        this.testOnBorrow = testOnBorrow;
    }

    public Boolean getTestOnReturn() {
        return testOnReturn;
    }

    public void setTestOnReturn(Boolean testOnReturn) {
        this.testOnReturn = testOnReturn;
    }

    public Boolean getPoolPreparedStatements() {
        return poolPreparedStatements;
    }

    public void setPoolPreparedStatements(Boolean poolPreparedStatements) {
        this.poolPreparedStatements = poolPreparedStatements;
    }

    public Integer getMaxOpenPreparedStatements() {
        return maxOpenPreparedStatements;
    }

    public void setMaxOpenPreparedStatements(Integer maxOpenPreparedStatements) {
        this.maxOpenPreparedStatements = maxOpenPreparedStatements;
    }

    public Boolean getRemoveAbandoned() {
        return removeAbandoned;
    }

    public void setRemoveAbandoned(Boolean removeAbandoned) {
        this.removeAbandoned = removeAbandoned;
    }

    public Integer getRemoveAbandonedTimeout() {
        return removeAbandonedTimeout;
    }

    public void setRemoveAbandonedTimeout(Integer removeAbandonedTimeout) {
        this.removeAbandonedTimeout = removeAbandonedTimeout;
    }

    public String getFilters() {
        return filters;
    }

    public void setFilters(String filters) {
        this.filters = filters;
    }

    @Override
    public String toString() {
        StringBuffer druidConfig = new StringBuffer();
        druidConfig.append("driver:" + getDriverClassName() + ",");
        druidConfig.append("url:" + this.getUrl() + ",");
        druidConfig.append("username:" + this.getUsername() + ",");
        druidConfig.append("password:" + this.getPassword() + ",");
        druidConfig.append("initialSize:" + this.getInitialSize() + ",");
        druidConfig.append("maxActive:" + this.getMaxActive() + ",");
        druidConfig.append("minIdle:" + this.getMinIdle() + ",");
        druidConfig.append("maxWait:" + this.getMaxWait() + ",");
        // druidConfig.append("url:"+this.getMaxPoolPreparedStatementPerConnectionSize()+",");
        // druidConfig.append(this.getPoolPreparedStatements()+",");
        // druidConfig.append(this.getTestOnBorrow()+",");
        return druidConfig.toString();
    }
}